home *** CD-ROM | disk | FTP | other *** search
/ Speccy ClassiX 1998 / Speccy ClassiX 98.iso / amiga_system / the_aminet / comm / bbs / maxsutils.lha / MaxUtils / Maxcps54.lha / MaxCPS.S < prev    next >
Text File  |  1993-04-14  |  12KB  |  541 lines

  1. ;--------------------------------------------------------------------
  2. ;
  3. ;            -----------------
  4. ;            ** M A X C P S **
  5. ;            **    V1.54    **
  6. ;            -----------------
  7. ;   
  8. ;    Program to Calculate the Top Transfers Speeds
  9. ;
  10. ;    of People Downloading Files from MaxsBBS V1.52
  11. ;
  12. ;
  13. ;    Written by:        Greg MacDonald
  14. ;    Using:            Devpac 3    
  15. ;    Date:            12-April-1993
  16. ;
  17. ;    Version            1.54
  18. ;
  19. ;--------------------------------------------------------------------
  20.  
  21.     Opt    C-
  22.  
  23. InitOffSet    =    281            ;OffSet to Start of Area in
  24.                         ;ANSI screen to start printing
  25. LineOffSet    =    65            ;Distance from one line to the
  26.                         ;next in the ansi text
  27.  
  28. AllTimeOffSet    =    1027-16            ;OffSet for All Time Highest
  29.                         ;CPS
  30.  
  31. NumLog        =    20            ;Number of Download to Check Back
  32.                         ;thru
  33.  
  34. MaxCPS:        bsr    OpenDos            ;Open Dos Library
  35.         tst.l    d0
  36.         beq.s    Exit1
  37.  
  38.         bsr    LoadAnsi        ;Load Ansi Screen if Available
  39.  
  40.         bsr    ExamineFile        ;Examine Download Log Size
  41.         tst.l    d0
  42.         beq.s    Exit2
  43.  
  44.         bsr    AllocMem        ;Allocate Mem for Dload Log
  45.         tst.l    d0
  46.         beq.s    Exit2
  47.  
  48.         bsr    LoadLog            ;Load Dload Log to Memory
  49.         cmp.l    #-1,d0
  50.         beq.s    Exit3
  51.  
  52.         bsr    StartLog        ;Find Start of Last X Entries
  53.  
  54.         bsr    GetMaxCPS        ;Find MAX CPS Values
  55.  
  56.         bsr    GetNames        ;Get Names for Max CPS Values
  57.  
  58.         bsr    AllTimeBest
  59.  
  60.         bsr    SaveFile        ;Save Out Ansi Screen
  61.         cmp.l    #-1,d0
  62.         beq.s    Exit3
  63.  
  64.         Nop
  65. Exit3:        bsr    DeAllocMem
  66. Exit2:        bsr    CloseDos
  67. Exit1:        moveq    #0,d0
  68.         rts
  69.  
  70.         dc.b    '$VER:MAXCPS 1.54 (14.4.93)',10
  71.         dc.b    'By Greg MacDonald',10
  72.         dc.b    'Call ENCONN BBS   +61-2-5241584',10,0
  73.         Even
  74.  
  75. ;--------------------------------------------------------------------
  76. ;
  77. ;    Open Dos Library and Get Base Address
  78. ;
  79. ;--------------------------------------------------------------------
  80.  
  81. DosBase:    dc.l    0            ;Base Address of Dos Library
  82. DosName:    dc.b    'dos.library',0
  83.         Even
  84.  
  85. OpenDos:    moveq    #0,d0
  86.         Lea    DosName(pc),a1
  87.         move.l    4.w,a6
  88.         jsr    -408(a6)        ;Open Library
  89.         move.l    d0,DosBase
  90.         rts        
  91.  
  92. ;--------------------------------------------------------------------
  93. ;
  94. ;    Close the Dos Library
  95. ;
  96. ;--------------------------------------------------------------------
  97.  
  98. CloseDos:    move.l    4.w,a6
  99.         move.l    DosBase(pc),a1
  100.         jsr    -414(a6)        ;Close Library
  101.         rts
  102.  
  103. ;--------------------------------------------------------------------
  104. ;
  105. ;    Examine File for Length so we can Allocate Memory
  106. ;
  107. ;--------------------------------------------------------------------
  108.  
  109. Lock:        dc.l    0            ;Lock for Download Log
  110. Name:        dc.b    'BBS:LogFiles/DnLoadLog.Text',0
  111.         ds.b    22
  112.         Even
  113.  
  114. ExamineFile:    moveq    #-2,d2
  115.         move.l    #Name,d1
  116.         move.l    DosBase(pc),a6
  117.         jsr    -84(a6)            ;Lock
  118.         move.l    d0,d1
  119.         beq.s    ExamineError
  120.         move.l    d0,Lock
  121.  
  122.         move.l    #FileInfoBlock,d2
  123.         jsr    -102(a6)        ;Examine
  124.         move.l    d0,-(a7)        ;Save for a Sec
  125.  
  126.         move.l    Lock(pc),d1
  127.         jsr    -90(a6)            ;UnLock
  128.  
  129.         move.l    (a7)+,d0
  130. ExamineError:    rts
  131.  
  132. ;--------------------------------------------------------------------
  133. ;
  134. ;    Alocates Memory for Loading in Download Log
  135. ;
  136. ;--------------------------------------------------------------------
  137.  
  138. MemBase:    dc.l    0            ;Address of Download Log
  139. MemSize:    dc.l    0            ;Size of Download Log
  140.  
  141. AllocMem:    move.l    4.w,a6
  142.         lea    FileInfoBlock,a0
  143.         move.l    124(a0),d0
  144.         move.l    d0,MemSize
  145.         tst.l    d0
  146.         beq.s    AllocError
  147.         moveq    #0,d1
  148.         jsr    -198(a6)        ;Allocate Memory
  149.         move.l    d0,MemBase
  150. AllocError:    rts
  151.  
  152. ;--------------------------------------------------------------------
  153. ;
  154. ;    De-Allocated Memory for Loading in Download Log
  155. ;
  156. ;--------------------------------------------------------------------
  157.  
  158. DeAllocMem:    move.l    4.w,a6
  159.         move.l    MemBase(pc),a1
  160.         move.l    MemSize(pc),d0
  161.         jsr    -210(a6)        ;Free Memory
  162.         rts
  163.  
  164. ;--------------------------------------------------------------------
  165. ;
  166. ;    Load Download Log Into Memory
  167. ;
  168. ;--------------------------------------------------------------------
  169.  
  170. FileHandle:    dc.l    0            ;File Handle For Log File
  171.  
  172. LoadLog:    move.l    DosBase(pc),a6
  173.         move.l    #Name,d1
  174.         move.l    #1005,d2        ;Read Only
  175.         jsr    -30(a6)            ;Open File
  176.         move.l    d0,FileHandle
  177.         tst.l    d0
  178.         beq.s    LoadError
  179.  
  180.         move.l    d0,d1            ;Handle
  181.         move.l    MemBase(pc),d2
  182.         move.l    MemSize(pc),d3
  183.         jsr    -42(a6)            ;Read File
  184.  
  185.         move.l    d0,-(a7)        ;Save For a Sec
  186.  
  187.         move.l    FileHandle(pc),d1
  188.         jsr    -36(a6)            ;Close File
  189.  
  190.         move.l    (a7)+,d0
  191.         rts
  192.  
  193. LoadError:    moveq    #-1,d0
  194.         rts
  195.  
  196. ;--------------------------------------------------------------------
  197. ;
  198. ;    Save OutPut File to RAM
  199. ;
  200. ;--------------------------------------------------------------------
  201.  
  202. SaveName:    dc.b    'Ram:MaxsFiles/MaxCPS.Ansi',0
  203.         ds.b    50-27
  204.         Even
  205.  
  206. SaveFile:    move.l    DosBase(pc),a6
  207.         move.l    #SaveName,d1
  208.         move.l    #1006,d2
  209.         jsr    -30(a6)            ;Open File
  210.         move.l    d0,FileHandle
  211.         move.l    d0,d1        
  212.         beq.s    SaveError
  213.  
  214.         move.l    #SaveBuffer,d2
  215.  
  216.         move.l    #EndSave-SaveBuffer,d3    ;Length to Save
  217.         jsr    -48(a6)
  218.         move.l    d0,-(a7)        ;Save for Later
  219.  
  220.         move.l    FileHandle(pc),d1
  221.         jsr    -36(a6)            ;Close File
  222.  
  223.         move.l    (a7)+,d0
  224.         rts
  225.  
  226. SaveError:    moveq    #-1,d0
  227.         rts
  228.  
  229.  
  230. ;--------------------------------------------------------------------
  231. ;
  232. ;    Get to Start of Last "NumLog" Downloads
  233. ;
  234. ;--------------------------------------------------------------------
  235.  
  236. StartLog:    move.l    MemBase(pc),a0
  237.         move.l    a0,a6
  238.         add.l    MemSize(pc),a6            ;End of Log File
  239.         moveq    #0,d7                ;Counter
  240.  
  241. SearchLog:    cmp.l    a0,a6
  242.         ble.s    EndLog    
  243.         cmp.b    #$0a,(a6)
  244.         beq.s    FoundReturn
  245. RetFound:    subq.w    #1,a6
  246.         bra.s    SearchLog
  247.  
  248. EndLog:        move.l    MemBase(pc),StartBase
  249.         rts
  250.  
  251. FoundReturn:    addq.w    #1,d7
  252.         cmp.w    #NumLog+1,d7
  253.         blt.s    RetFound
  254.         move.l    a6,StartBase
  255.         rts
  256.  
  257. StartBase:    dc.l    0                ;Where to Start Looking
  258.                             ;For Download CPS Values
  259.  
  260. ;--------------------------------------------------------------------
  261. ;
  262. ;    Get 10 Highest CPS from DownLoad Log File
  263. ;
  264. ;
  265. ;    Search for a ", " the cps value is after that and is
  266. ;    terminated by a return (10 decimal).
  267. ;
  268. ;    What this does first is go thru the log file and collects
  269. ;    all the cps values and finds the current 10 highest
  270. ;
  271. ;--------------------------------------------------------------------
  272.  
  273. CPSNUM:        dc.w    -1                ;How Many CPS Added
  274.  
  275. GetMaxCPS:    move.l    MemBase(pc),a0
  276.         move.l    a0,a6
  277.         add.l    MemSize(pc),a6            ;End of Log File
  278.         move.l    StartBase(pc),a0
  279.  
  280. MaxLoop1:    move.b    (a0),d0
  281.         cmp.b    #',',d0
  282.         beq.s    FoundCPS
  283.         addq.w    #1,a0
  284.         cmp.l    a0,a6
  285.         bgt.s    MaxLoop1
  286.         rts
  287.  
  288. FoundCPS:    addq.w    #2,a0                ;Get to CPS Value
  289.         move.l    a0,a5                ;Keep Address
  290.         move.l    #$20202020,d0            ;All Spaces
  291.         moveq    #4,d7                ;Max CPS is 9999
  292.  
  293. FoundCPS2:    move.b    (a0)+,d1
  294.         cmp.b    #10,d1                ;Return
  295.         beq.s    FoundCPS3
  296.         lsl.l    #8,d0
  297.         move.b    d1,d0
  298.         dbf    d7,FoundCPS2
  299.         bra.s    MaxLoop1            ;Must have been No Return
  300.  
  301. FoundCPS3:    lea    StoredCPS,a1
  302.         moveq    #-1,d7
  303.  
  304. FoundCPS4:    addq.w    #1,d7
  305.         cmp.l    (a1),d0
  306.         bge.s    NewCPS                ;UpDate CPS
  307.         add.w    #12,a1                ;Down One CPS
  308.         cmp.w    #9,d7
  309.         blt.s    FoundCPS4
  310.         bra.s    MaxLoop1            ;CPS Too Small
  311.  
  312. NewCPS:        addq.w    #1,CPSNUM
  313.         moveq    #10-1,d6            ;Copy Lower CPS's
  314.         lea    StoredCPS+10*12,a1
  315.         sub.w    d7,d6                ;Down the List
  316.  
  317. NewCPS1:     sub.w    #12,a1
  318.         move.l    (a1),12(a1)            ;CPS
  319.         move.l    4(a1),16(a1)            ;Address of Name
  320.          dbf    d6,NewCPS1
  321.         move.l    d0,(a1)+            ;New CPS
  322.         move.l    a5,(a1)                ;New Address
  323.         bra    MaxLoop1
  324.  
  325. ;CPS Speeds Stored Highest to Lowest
  326.  
  327. StoredCPS:    dcb.l    11*3,0                ;First Long Word = CPS
  328.                             ;2nd Long Word = Address
  329.  
  330. ;--------------------------------------------------------------------
  331. ;
  332. ;    Gets Names from Address Stored with StoredCPS
  333. ;
  334. ;--------------------------------------------------------------------
  335.  
  336. GetNames:    lea    StoredCPS+4(pc),a0        ;First Replaces CPS
  337.         moveq    #10-1,d7            ;Address with that
  338.                             ;of the Users Name.
  339. ;----    Find Start Address of Name
  340.  
  341. Get1:        move.l    (a0),a1
  342.         move.l    a1,4(a0)            ;For End of Name Stuff
  343.         addq.w    #1,a1
  344. Get2:        subq.w    #1,a1
  345.         cmp.b    #$0a,(a1)            ;Return Character
  346.         bne.s    Get2
  347.  
  348. Get3:        addq.w    #1,a1
  349.         moveq    #0,d0
  350. Get4:        addq.w    #1,a1                ;Go Forward 7 Spaces
  351.         cmp.b    #' ',(a1)
  352.         bne.s    Get4
  353.         addq.w    #1,d0
  354.         cmp.w    #6,d0
  355.         blt.s    Get4
  356.         move.l    a1,(a0)                ;Save Start Address of Name
  357.         add.w    #12,a0                ;Next Lot of Data
  358.         dbf    d7,Get1
  359.  
  360. ;----    Find End Address of Name
  361.  
  362.         lea    StoredCPS+8(pc),a0
  363.         moveq    #10-1,d7
  364.  
  365. Get7:        move.l    (a0),a1
  366.         addq.w    #1,a1
  367.         moveq    #0,d0
  368. Get8:        subq.w    #1,a1                ;Go Backward 3 Spaces
  369.         cmp.b    #' ',(a1)
  370.         bne.s    Get8
  371.         addq.w    #1,d0
  372.         cmp.w    #3,d0
  373.         blt.s    Get8
  374.         move.l    a1,(a0)                ;Save End Address of Name
  375.         add.w    #12,a0
  376.         dbf    d7,Get7
  377.  
  378. ClearSave:    lea    SaveBuffer+InitOffSet,a0
  379.         moveq    #$20,d0
  380.         moveq    #10-1,d7
  381.  
  382. Clear1:        move.w    #45-1,d6
  383. Clear2:        move.b    d0,(a0)+
  384.         dbf    d6,Clear2
  385.         add.w    #20,a0
  386.         dbf    d7,Clear1
  387.  
  388. PrintNames:    lea    StoredCPS(pc),a0
  389.         lea    SaveBuffer+InitOffSet,a6
  390.         move.w    CPSNum(pc),d7
  391.         bmi.s    EndPrint        ;No CPS Values Added
  392.         cmp.w    #10-1,d7
  393.         ble.s    Print1            ;Less or = to 10-1
  394.         moveq    #10-1,d7
  395.  
  396. Print1:        lea    LineOffSet(a6),a5    ;Next Line
  397.         move.l    (a0)+,d0
  398.         move.b    d0,43(a6)
  399.         lsr.l    #8,d0
  400.         move.b    d0,42(a6)
  401.         lsr.l    #8,d0
  402.         move.b    d0,41(a6)
  403.         lsr.w    #8,d0
  404.         move.b    d0,40(a6)
  405.  
  406.         move.l    (a0)+,a1        ;Start of Name Address
  407.         move.l    (a0)+,a2        ;End of Name Address
  408.         moveq    #36-1,d6        ;Max 35 Chars for Name        
  409.  
  410. Print2:        move.b    (a1)+,(a6)+
  411.         cmp.l    a2,a1
  412.         bge.s    Print3            ;End of Name
  413.         dbf    d6,Print2
  414. Print3:        move.l    a5,a6
  415.         dbf    d7,Print1
  416. EndPrint:    rts
  417.  
  418. ;--------------------------------------------------------------------
  419. ;
  420. ;    Load Pevious Ansi Screen Into Memory
  421. ;
  422. ;    -    If Ram:MaxsFiles/MaxCPS.Ansi exists then it's loaded
  423. ;    -    Else the built in Ansi screen is used
  424. ;
  425. ;--------------------------------------------------------------------
  426.  
  427. LoadAnsi:    move.l    DosBase(pc),a6
  428.         move.l    #AnsiName,d1
  429.         move.l    #1005,d2        ;Read Only
  430.         jsr    -30(a6)            ;Open File
  431.         tst.l    d0
  432.         beq.s    AnsiError
  433.  
  434.         move.l    d0,-(a7)        ;Save Handle
  435.         move.l    d0,d1            ;Handle
  436.         move.l    #SaveBuffer,d2
  437.         move.l    #EndSave-SaveBuffer,d3
  438.         jsr    -42(a6)            ;Read File
  439.  
  440.         move.l    (a7)+,d1        ;File Handle
  441.         jsr    -36(a6)            ;Close File
  442. AnsiError:    rts
  443.  
  444. AnsiName:    dc.b    'ram:maxsfiles/MaxCPS.Ansi',0
  445.  
  446. SaveBuffer:    Incbin    Ram:MAXCPS.Text
  447. EndSave:
  448.  
  449. ;--------------------------------------------------------------------
  450. ;
  451. ;    Check All Time Highest CPS Rate
  452. ;
  453. ;--------------------------------------------------------------------
  454.  
  455. AllTimeBest:    lea    SaveBuffer+AllTimeOffSet(pc),a0
  456.         cmp.b    #'.',43(a0)        ;CPS Data
  457.         beq.s    NewBest
  458.  
  459.         lea    40(a0),a0
  460.         bsr    AsciiToHex
  461.         move.l    d1,d2
  462.  
  463.         lea    SaveBuffer+InitOffSet+40,a0
  464.         bsr    AsciiToHex
  465.  
  466.         cmp.l    d2,d1
  467.         bgt.s    NewBest            ;Equal or Higher Value
  468.  
  469.         rts
  470.  
  471. ;--------------------------------------------------------------------
  472. ;
  473. ;    UpDate All Time Highest CPS Rate
  474. ;
  475. ;--------------------------------------------------------------------
  476.  
  477. NewBest:    lea    SaveBuffer+InitOffSet(pc),a0    ;Source
  478.         lea    SaveBuffer+AllTimeOffSet(pc),a1        ;Destination
  479.         moveq    #45-1,d7
  480.  
  481. NewBest1:    move.b    (a0)+,(a1)+
  482.         dbf    d7,NewBest1
  483.         rts
  484.  
  485. ;--------------------------------------------------------------------
  486. ;
  487. ;    Converts 4 Digit Decimal Ascii to LongWord Hex sort Of.
  488. ;
  489. ;    Not actually Hex, but if you compare 2 numbers got from here
  490. ;    you can say one is bigger than the other
  491. ;
  492. ;--------------------------------------------------------------------
  493.  
  494. AsciiToHex:    moveq    #0,d1
  495.  
  496.         moveq    #0,d0
  497.         move.b    (a0)+,d0
  498.         cmp.b    #' ',d0
  499.         bne.s    NoSpace1
  500.         moveq    #'0',d0
  501. NoSpace1:    ror.l    #8,d0
  502.         or.l    d0,d1
  503.  
  504.         moveq    #0,d0
  505.         move.b    (a0)+,d0
  506.         cmp.b    #' ',d0
  507.         bne.s    NoSpace2
  508.         moveq    #'0',d0
  509. NoSpace2:    ror.l    #8,d0
  510.         ror.l    #8,d0
  511.         or.l    d0,d1
  512.  
  513.         moveq    #0,d0
  514.         move.b    (a0)+,d0
  515.         cmp.b    #' ',d0
  516.         bne.s    NoSpace3
  517.         moveq    #'0',d0
  518. NoSpace3:    rol.l    #8,d0
  519.         or.l    d0,d1
  520.  
  521.         moveq    #0,d0
  522.         move.b    (a0)+,d0
  523.         cmp.b    #' ',d0
  524.         bne.s    NoSpace4
  525.         moveq    #'0',d0
  526. NoSpace4:    or.l    d0,d1
  527.         rts
  528.         
  529. ;--------------------------------------------------------------------
  530. ;
  531. ;        File Info Block for Examine Command
  532. ;
  533. ;    - The Setion Statement is so that it is LongWord Aligned
  534. ;    - The BSS means it takes up No DiskSpace.IE All Zeros
  535. ;--------------------------------------------------------------------
  536.  
  537.         Section    FileInfoblock,BSS
  538.  
  539. FileInfoBlock:    ds.l    260            ;260 Long Words of FileInfo
  540.